"""财务页面基类"""
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class FinancialPage(BasePage):

    url='/crm/index.php?m=finance'
    # 添加应收款定位器
    add_ysk_locator = (By.XPATH, "/html/body/div[5]/div[2]/div[1]/div[3]/a[1]")
    # 第2页
    twoye_locator=(By.CSS_SELECTOR,'#form1 > table > tfoot > tr:nth-child(2) > td > div.pagination > div.span4 > div > ul > li:nth-child(3) > a:nth-child(2)')
    # 首页
    first_page_locator=(By.LINK_TEXT,'首页')
    #应收款
    yingshoukuan_locator = (By.CSS_SELECTOR, 'body > div.container > div.page-header > ul > li.active > a')
    #统计
    cwtj_locator = (By.CSS_SELECTOR, 'body > div.container > div.page-header > ul > li:nth-child(5) > a')
    # 添加收款单
    add_shoukuandan_locator = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/div[3]/a[2]')
    # 今日应收
    today_locator = (By.XPATH, '/html/body/div[5]/p/a[9]')
    # 选择统计内容
    tjneirong_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div.span2.knowledgecate > ul > li.active > a')
    # 月度统计
    yuedutj_locator = (By.CSS_SELECTOR, '#show_moon')
    # 统计报表
    cwtj_baobiao_locator = (By.XPATH, '//*[@id="show_report"]')
    #年度统计
    nainduyfk_locator = (By.CSS_SELECTOR, '#show_fukuan')
    #断言添加成功
    duanyan_add_success_locator=(By.CLASS_NAME,'alert-success')
    #财务信息月度统计
    cw_yuedutj_locator=(By.CSS_SELECTOR,'#highcharts-0 > svg > text.highcharts-title')
    #应付款年度同比
    cw_niandutj_locator=(By.CSS_SELECTOR,'#highcharts-4 > svg > text.highcharts-title')
    # 选择第一条删除
    choice_first_delete_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    # 点击删除
    click_delete_locator = (By.CSS_SELECTOR, '#delete')

    #点击应收款
    def click_ysk(self):
        self.driver.find_element(*self.yingshoukuan_locator).click()

    #点击添加应收款
    def click_add_ysk(self):
        self.driver.find_element(*self.add_ysk_locator).click()

    #点击第2页
    def click_ysk_nextyiye(self):
        self.driver.find_element(*self.twoye_locator).click()

    #点击首页
    def click_ysk_shouye(self):
        self.driver.find_element(*self.first_page_locator).click()

    #点击统计
    def click_cw_tj(self):
        self.driver.find_element(*self.cwtj_locator).click()
    #选择统计内容
    def click_cwtj_neirong(self):
        self.driver.find_element(*self.tjneirong_locator).click()

    #选择财务统计报表
    def click_cwtj_baobiao(self):
        self.driver.find_element(*self.cwtj_baobiao_locator).click()

    #选择月度统计
    def click_cwtj_yuedutj(self):
        self.driver.find_element(*self.yuedutj_locator).click()

    #选择应付款年度同比
    def click_cwtj_niandutj(self):
        self.driver.find_element(*self.nainduyfk_locator).click()

    #点击新建收款单
    def click_add_shoukuandan(self):
        self.driver.find_element(*self.add_shoukuandan_locator).click()
   #点击今日应收
    def click_todayshoude(self):
        self.driver.find_element(*self.today_locator).click()

    #断言添加成功
    def tips_add_ysk_success(self):
        tips=self.driver.find_element(*self.duanyan_add_success_locator).text
        return tips
    #财务信息月度统计
    def message_yuedutj(self):
        yuedutj = self.driver.find_element(*self.cw_yuedutj_locator).text
        return yuedutj

    #应付款年度同比
    def message_niandutj(self):
        niandutj = self.driver.find_element(*self.cw_niandutj_locator).text
        return niandutj
    # 获取末页url
    def get_last_url(self):
        return self.current_url()
        # 点击第一条删除

    def click_first_delete(self):
        self.driver.find_element(*self.choice_first_delete_locator).click()

        # 点击删除

    def click_first_sure(self):
        self.driver.find_element(*self.click_delete_locator).click()
